package com.adms.controller;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.adms.domain.ReformExecute;
import com.adms.service.ReformExecuteService;

@RequestMapping("reform/execute")
@RestController
public class ReformExecuteController {

	@Autowired
	private ReformExecuteService reformExecuteService;
	
	@GetMapping("{executeId}")
	public Object getByExecuteId(@PathVariable("executeId") Integer executeId) {
		return reformExecuteService.getByExecuteId(executeId);
	}
	
	@GetMapping("getWithReform")
	public Object getByExecuteIdWithReform(@RequestParam("executeId") Integer executeId) {
		return reformExecuteService.getByExecuteIdWithReform(executeId);
	}
	
	@GetMapping
	public Object list(ReformExecute reformExecute,String timeField,Date start,Date end,String orderByClause,
			@RequestParam(defaultValue = "1") Integer pageNum,
			@RequestParam(defaultValue = "5") Integer pageSize,
			@RequestParam(defaultValue = "5") Integer navigatePages) {
		return reformExecuteService.list(reformExecute,timeField,start,end,orderByClause,pageNum,pageSize,navigatePages);
	}
	
	@PostMapping("audit")
	public Object audit(@RequestParam("executeId") Integer executeId,
			@RequestParam("reformId") Integer reformId,
			@RequestParam("auditState") Integer auditState,
			@RequestParam("auditView") String auditView) {
		return reformExecuteService.audit(executeId,reformId,auditState,auditView);
	}
	
}
